import sun.reflect.generics.tree.Tree;

import javax.swing.tree.TreeNode;
import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * user:likai
 * Date:2022-11-21
 * Time:11:01
 */
public class Test {
    class TreeNode{
        int val;

        public TreeNode(int val) {
            this.val = val;
        }

        TreeNode left;
        TreeNode right;
    }
    public List<Integer> preorderTraversal(TreeNode root) {
        Stack <TreeNode> stack=new Stack<>();
        List <Integer> list=new LinkedList<>();
        if(root==null){
            return list;
        }
        while(root!=null||!stack.isEmpty()){
            if(root!=null){
                list.add(root.val);
                stack.push(root);
                root=root.left;
            }else{
                root=stack.pop().right;
            }
        }
        return list;
    }
    public TreeNode buildTree(int[] inorder, int[] postorder) {
        int begin=0;;
        int end=postorder.length-1;
        int mid=search(postorder[end],inorder);
        TreeNode root=new TreeNode(postorder[end]);
        root.right=buildTreeChild(inorder,postorder,mid+1,end);
        root.left=buildTreeChild(inorder,postorder,begin,mid-1);
        return root;
    }
    int now=1;
    public int search(int cur,int []inorder){
        for(int i=0;i<inorder.length;i++){
            if(cur==inorder[i]){
                return i;
            }
        }
        return -1;
    }
    public TreeNode buildTreeChild(int[]inorder,int[]postorder,int begin,int end){
        if(begin>end){
            return null;
        }
        TreeNode root=new TreeNode(postorder[postorder.length-1-now]);
        int mid=search(root.val,inorder);
        if(mid==-1){
            return null;
        }
        now++;
        if(begin==end){
            return root;
        }
        root.right=buildTreeChild(inorder,postorder,mid+1,end);
        root.left=buildTreeChild(inorder,postorder,begin,mid-1);
        return root;
    }
    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> list=new LinkedList<>();
        Stack<TreeNode> stack=new Stack<>();
        if(root==null){
            return list;
        }

        while(root!=null||!stack.isEmpty()){
            while(root!=null){
                stack.push(root);
                root=root.left;
            }
            TreeNode cur=stack.pop();
            list.add(cur.val);
            root=cur.right;
        }
        return list;
    }
    public static void main1(String[] args) {
        int []array=new int[2];
        array[0]=1;
        System.out.println(Arrays.toString(array));
    }
    public static void main2(String[] args){
        String s1;
        String s2;
        Scanner scanner=new Scanner(System.in);
        s1=scanner.nextLine();
        s2=scanner.nextLine();
        int length=s1.length();
        int i=0;
        int n=0;
        char[]array=new char[length];
        while(i<length){
            char cur=s1.charAt(i);
            int j=0;
            while(j<s2.length()&&s2.charAt(j)!=cur){
                j++;
            }
            if(j==s2.length()){
                array[n++]=cur;
            }
            i++;
        }

    }


}
